package org.easydev.base.webbase.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.properties.SwaggerUiConfigProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;

@Configuration
@Profile("local")
public class SwaggerConfig {


    @Value("${easy-dev.web.swagger.title:swagger title}")
    private String title;

    @Value("${easy-dev.web.swagger.description:swagger description}")
    private String description;

    @Value("${easy-dev.web.swagger.version:1.0.0}")
    private String version;

    @Bean
    public OpenAPI openAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title(title)
                        .version(version)
                        .description(description));
    }

    @Bean
    @Primary
    public SwaggerUiConfigProperties swaggerUiConfigProperties() {
        SwaggerUiConfigProperties swaggerUiConfigProperties = new SwaggerUiConfigProperties();
        swaggerUiConfigProperties.setDefaultModelExpandDepth(-1);
        swaggerUiConfigProperties.setDefaultModelExpandDepth(-1);
        return swaggerUiConfigProperties;
    }
}
